package com.hbue.springboot.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hbue.springboot.pojo.Result;
import com.hbue.springboot.pojo.TbWorker;
import com.hbue.springboot.service.TbWorkerService;
import com.hbue.springboot.service.WaterCountStatService;
import com.hbue.springboot.vo.QueryParamsVo;
import com.hbue.springboot.vo.WaterCountStatVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/stat")
@RequiredArgsConstructor
@Slf4j
public class WaterCountStatController {

    private final WaterCountStatService waterCountStatService;

    /**
     * 统计每个送水工送水数量和客户列表
     * @param query 前端采集的参数
     * @return 分页对象
     */
    @PostMapping("/listWorkerSendWaterCount")
    public Result listWorkerSendWaterCount(@RequestBody QueryParamsVo query) {
        log.info("listWorkerSendWaterCount query = "+query);
        IPage<WaterCountStatVo> page = waterCountStatService.listWorkerSendWaterCount(query);
        return page.getTotal() > 0 ? Result.success(page) : Result.error("没有找到送水工信息");
    }
}
